package com.indusfo.spc.client.controller;

import com.indusfo.spc.annotation.UserLoginToken;
import com.indusfo.spc.client.service.ClientSopService;
import com.indusfo.spc.vo.JSONObject;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 客户端SOP控制层
 * 
 * @author zhengd
 * @create 2019-12-11
 */
@RestController
@RequestMapping("/client/sop")
public class ClientSopController {

	@Autowired
	private ClientSopService clientSopService;

	/**
	 * 根据批号查询地址
	 * 
	 * @param batchCode
	 * @param stationId
	 * @return
	 */
	@PostMapping("/queryClientSopByBatchCode")
	@UserLoginToken
	public JSONObject queryClientSopByBatchCode(@RequestBody Map<String, String> map) {
		try {
			return JSONObject.oK(clientSopService.queryClientSopByBatchCode(map.get("batchCode"),
					Integer.parseInt(map.get("stationId"))));
		} catch (Exception e) {
			return JSONObject.build(JSONObject.ERROR, "系统错误，请联系管理员！");
		}
	}

}
